<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Api_Model_City
{
	private $city_id;
	private $name;
	private $created_time;
	private $updated_time;

	public function __construct($city_row = null) {
		if(!is_null($city_row) && $city_row instanceof Zend_Db_Table_Row) {
			$this->city_id = $city_row->city_id;
			$this->name = $city_row->name;
			$this->created_time = $city_row->created_time;
			$this->updated_time = $city_row->updated_time;
		}
	}

	public function __set($name, $value) {
		switch($name) {
			case 'city_id':
				if(!is_null($this->city_id)) {
					throw new Exception('Cannot update city\'s id');
				}
				break;
			case 'name':
				if(!is_null($this->name)) {
					throw new Exception('Cannot update city name');
				}
				break;
			case 'created_time':
				if(!is_null($this->created_time)) {
					throw new Exception('Cannot created time');
				}
				break;
			case 'updated_time':
				if(!is_null($this->updated_time)) {
					throw new Exception('Cannot update content');
				}
				break;
		}
		$this->$name = $value;
	}

	public function __get($name) {
		return $this->$name;
	}
}

